package wzh.crm.bl;

import android.os.AsyncTask;

import java.util.concurrent.ExecutionException;

import wzh.crm.db.CURDDB;
import wzh.crm.vo.ContactVo;
import wzh.crm.vo.CustomerVo;

/**
 * Created by wangzehao on 2016/6/20.
 */
public class CustomerBL extends CURDBL<CustomerVo> {
    CustomerBL(CURDDB<CustomerVo> db) {
        super(db);
    }

    public String getCustomerNameInBackGround(final int id) {
        AsyncTask<Object, Object, String> asyncTask=new AsyncTask<Object, Object, String>() {

            @Override
            protected String doInBackground(Object... params) {
                return getCustomerName(id);
            }
        };
        asyncTask.execute(new Object());
        String name= "";
        try {
            name = asyncTask.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        return name;

    }

    public String getCustomerName(final int id) {
        try {
            return CustomerBL.this.get(id).get客户名称();
        } catch (Exception e) {
            e.printStackTrace();
            return "id:"+id;
        }
    }
}
